package fybug.nulll.pdstream.IO.Error;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;

import java.io.InputStream;
import java.io.OutputStream;

import fybug.nulll.pdfunctionlibrary.Processing.Check;

import static fybug.nulll.pdfunctionlibrary.Processing.Check.equalsFidle;
/**
 * <h2>表示在进行流操作的过程中发生错误.</h2>
 * <pre>
 * 记录错误信息和发生错误的流
 * {@link #instream}
 * {@link #outstream}
 * </pre>
 *
 * @author fybug
 * @version 0.0.7
 * @see Exception
 * @see InputStream
 * @see OutputStream
 * @since JDK 1.8
 */
@SuppressWarnings( "all" )
public
class ByteStreamErr extends Exception {
    private static final long serialVersionUID = 2032079824484030076L;
    /** <p>发生异常的读取流.</p> */
    @Nullable final public InputStream instream;
    /** <p>发生异常的输出流.</p> */
    @Nullable final public OutputStream outstream;

    public
    ByteStreamErr(@NotNull final String message, @Nullable final InputStream stream,
            @Nullable final OutputStream outputStream)
    {
        super(message);
        this.instream = stream;
        this.outstream = outputStream;
    }

    @Override
    public
    boolean equals(@Nullable final Object obj) {
        switch ( Check.checkEquals(this, obj) ) {
            default:
                return false;
            case 1:
                return true;
            case 2:
                return equalsFidle(instream, ((ByteStreamErr) obj).instream) && equalsFidle(
                        outstream, ((ByteStreamErr) obj).outstream);
        }
    }
}
